package com.yitiao.demo100;

/**
 * 修改文件扩展名——字符串替换
 */
public class question_13 {
    public static void main(String[] args) {
        String path="c:\\myfile\\2021\\yitiao.txt";
        int index=path.lastIndexOf("\\");
        String fileName=path.substring(index+1);
        String newName=fileName.replaceAll(".txt",".java");
        System.out.println(path);
        System.out.println(fileName);
        System.out.println(newName);
    }
}
